package com.cloudkinto.service.stock;

import com.baomidou.mybatisplus.extension.service.IService;
import com.cloudkinto.bo.api.SkuAdjustApiBo;
import com.cloudkinto.bo.stock.*;
import com.cloudkinto.common.web.PageResult;
import com.cloudkinto.common.web.SingleResult;
import com.cloudkinto.dto.stock.NormalInputShelfDto;
import com.cloudkinto.dto.stock.TransferInputShelfDto;
import com.cloudkinto.dto.stock.adjust.box.BoxCellStockDto;
import com.cloudkinto.dto.stock.adjust.sku.SkuCellStockDto;
import com.cloudkinto.dto.stock.back.OrderReturnStockDto;
import com.cloudkinto.dto.stock.defective.SkuPickQueryBo;
import com.cloudkinto.dto.stock.defective.SkuStockForPickDto;
import com.cloudkinto.dto.stock.defective.SkuStockTotalDto;
import com.cloudkinto.dto.stock.query.ComplexStockTotalDto;
import com.cloudkinto.dto.stock.query.SkuStockDto;
import com.cloudkinto.dto.stock.query.SkuStockPageDto;
import com.cloudkinto.entity.ProductStockDo;
import com.cloudkinto.entity.ReplenishmentPlanDo;
import com.cloudkinto.service.platform.vo.product.StockToPlatformReq;
import com.cloudkinto.service.stock.vo.snap.ProductWeightReq;
import com.cloudkinto.vo.stock.adjust.box.AdjustItemRes;
import com.cloudkinto.vo.stock.adjust.box.BoxAdjustInitReq;
import com.cloudkinto.vo.stock.adjust.box.BoxAdjustReq;
import com.cloudkinto.vo.stock.adjust.box.BoxConvertReq;
import com.cloudkinto.vo.stock.adjust.sku.SkuAdjustInitReq;
import com.cloudkinto.vo.stock.adjust.sku.SkuAdjustReq;
import com.cloudkinto.vo.stock.move.BoxMoveReq;
import com.cloudkinto.vo.stock.move.sku.SkuMoveReq;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * service接口
 * </p>
 *
 * @author hua
 * @since 2024-10-28
 */
public interface ProductStockService extends IService<ProductStockDo> {

    List<OrderReturnStockDto> getReturnStockRecord(Long orderId);

    SingleResult pageInit(Long userId, Long tenantId, Long companyId, String source);

    List<TransferInputShelfDto> getTransferInputShelfData(List<Long> pasIdList);

    Collection<NormalInputShelfDto> getNormalInputShelfData(List<Long> pasIdList);

    void getStockAgeList();

    Object addWeight(ProductWeightReq req, Long userId, Long companyId);

    PageResult<SkuStockDto> productBySku(Map<String, Object> map);

    PageResult<SkuStockPageDto> productListPageBySku(ProductStockBySkuQueryBo req);

    PageResult productListPageByLocation(ProductStockByLocationQueryBo req);

    PageResult boxListPageByType(BoxStockByTypeQueryBo req);

    PageResult boxListPageByLocation(BoxStockByLocationQueryBo req);

    PageResult complexStockPage(Map<String, Object> map);

    ComplexStockTotalDto complexStock(Map<String, Object> map);

    boolean jugSkuStock(Map<Long, Integer> skuQtyMap, int stockAttribute, Long storageId, Long companyId);


    /**
     * 综合库存导出
     */
    void complexStockExport(Map<String, Object> map, HttpServletResponse response);


    List<BoxCellStockDto> boxCellStockList(BoxAdjustInitReq req, Long whId, Long tenantId);

    PageResult getBoxListForAdjust(Map<String, Object> map);

    List<AdjustItemRes> boxStockAdjust(BoxAdjustReq req, Long whId, Long userId, Long tenantId);

    List<AdjustItemRes> boxMoveStock(BoxMoveReq req, Long whId, Long userId, Long tenantId);

    List<SkuCellStockDto> skuCellStockList(SkuAdjustInitReq req, Long whId, Long tenantId);

    List<AdjustItemRes> skuStockAdjustApi(SkuAdjustApiBo req, Long whId, Long userId, Long tenantId);

    List<AdjustItemRes> skuStockAdjust(SkuAdjustReq req, Long whId, Long userId, Long tenantId);

    Map<String, Object> importSkuForAdjust(MultipartFile file, Long companyId);

    List<AdjustItemRes> skuMoveStock(SkuMoveReq req, Long whId, Long userId, Long tenantId);

    List<AdjustItemRes> boxConvert(BoxConvertReq req, Long whId, Long tenantId);

    List<SkuStockForPickDto> getStockForPickList(SkuPickQueryBo bo);

    int updateStockById(Long id, Long childId, int qty);

    PageResult getSkuStockTotalList(Map<String, Object> map);

    List<SkuStockTotalDto> getSkuStockTotal(SkuPickQueryBo bo);

    void ompExportBySku(ProductStockBySkuQueryBo bo, HttpServletResponse response) throws IOException;

    void omsExportBySku(ProductStockBySkuQueryBo bo, HttpServletResponse response) throws IOException;

    void ompExportByBoxTypeNo(BoxStockByTypeQueryBo bo, HttpServletResponse response) throws IOException;

    void omsExportByBoxTypeNo(BoxStockByTypeQueryBo bo, HttpServletResponse response) throws IOException;

    PageResult getProductLockingStockDetail(ProductStockLockingQueryBo req);

    PageResult getBoxLockingStockDetail(BoxStockLockingQueryBo req);

    void stockToPlatform(Long storeId);

    void stockToPlatform();

    void stockToPlatform(List<String> platforms, List<Long> storeIdList, List<String> platformSkuList, Integer inventoryLink, Long userId, String userName);

    void manalStockToPlat(StockToPlatformReq req, Long userId, String userName);

    List<ReplenishmentPlanDo> productByIds(Map map);


    PageResult supplementPlanListPage(Map<String, Object> map);

    void generateDocument(Map<String, Object> map);


    void updateReplenishmentPlan(List<ReplenishmentPlanDo> ReplenishmentPlanDo);


    void updateOrderStatus(@Param("ids") List<Long> ids);

    void exportProduct(Map<String, Object> map, HttpServletResponse response);

    void exportReplenishmentPlan(Map<String, Object> map, HttpServletResponse response);
}
